$(() => {
    function getOnlyWeather(city, cityID) {
        let result;
        let high;
        let low;
        let type;
        let fengxiang;
        let xmlhttp;
        if (window.XMLHttpRequest) {
            //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp = new XMLHttpRequest();
        } else {
            // IE6, IE5 浏览器执行代码
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        //建立连接
        xmlhttp.open("GET", "http://wthrcdn.etouch.cn/weather_mini?city=" + city, true);
        //发送请求
        xmlhttp.send();
        //响应
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
                let obj = JSON.parse(xmlhttp.responseText);     //  将json数据转换成对象
                let smg = obj.data.forecast;
                high = smg[0].high;
                low = smg[0].low;
                type = smg[0].type;
                fengxiang = smg[0].fengxiang;
                // let a = high.split(" ")[1];
                // result = type + " " + high + " " + low + " " + fengxiang;
                result = low.split(" ")[1] + " ~ " + high.split(" ")[1] + " " + fengxiang + " " + type;
                document.getElementById(cityID).innerText = result;
                //  添加天气图例
            }
        };
    }
    getOnlyWeather("长春","onlyWeather_cc");
});